package com.hivis.sms;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;

@Configuration
@PropertySource(value="classpath:sms.properties")
public class VipSmsConfig {
    public static String SERVER_IP;
    public static String ACCOUNT;
    public static String PASSWORD;
    public static String sourceNumber;
    public static String serviceCode;

    //要使用@Value 用${}占位符注入属性，这个bean是必须的，这个就是占位bean,另一种方式是不用value直接用Envirment变量直接getProperty('key')
    @Bean
    public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
        return new PropertySourcesPlaceholderConfigurer();
    }

    @Value("${sms.vipface.server}")
    public void setServerIp(String serverIp) {
        VipSmsConfig.SERVER_IP = serverIp;
    }

    @Value("${sms.vipface.acconut}")
    public void setACCOUNT(String ACCOUNT) {
        VipSmsConfig.ACCOUNT = ACCOUNT;
    }
    @Value("${sms.vipface.pw}")
    public void setPASSWORD(String PASSWORD) {
        VipSmsConfig.PASSWORD = PASSWORD;
    }
    @Value("${sms.vipface.sourceNumber}")
    public void setSourceNumber(String sourceNumber){
        VipSmsConfig.sourceNumber = sourceNumber;
    }
    @Value("${sms.vipface.serviceCode}")
    public void setServiceCode(String serviceCode){
        VipSmsConfig.serviceCode = serviceCode;
    }

    public static String getPASSWORD(){
        //TODO 密码解密
        return PASSWORD;
    }

}
